package flags

import (
	"flag"
	"fmt"
	"os"
)

var help bool
var conf string
var version bool

const VERSION = "v0.0.1 2023-7-14"

func init() {
	flag.BoolVar(&help, "h", false, "获取帮助")
	flag.BoolVar(&version, "v", false, "打印版本号")
	flag.StringVar(&conf, "c", "conf.yaml", "读取配置文件启动")
}

func InitFlag() {
	flag.Parse()

	flagHelp()
}

func flagHelp() {
	if help {
		flag.Usage()
		os.Exit(0)
	}
	if version {
		fmt.Println(VERSION)
		os.Exit(0)
	}
}

func ConfName() string {
	return conf
}
